package com.uenpay.im.invokeitems.chat;

import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;
import com.uenpay.im.invokeitems.BaseHttpInvokeItem;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;

/**
 * 删除群成员
 * @author SL
 * @copyRight http://www.qiyunxin.com
 */
public class RemoveGroupMemberInvokeItem extends BaseHttpInvokeItem {
	public class RemoveGroupMemberInvokeItemResult extends HttpInvokeResult {
		public int status;
		public String msg;
	}

	public RemoveGroupMemberInvokeItemResult getOutput() {
		return (RemoveGroupMemberInvokeItemResult) GetResultObject();
	}

	public RemoveGroupMemberInvokeItem(String chatId, String delId) {
		String url = APIConfiguration.getBaseUrl() + "Chat/Chat/deleteChatCusts?"
				+ APIConfiguration.getCustIdAndToken();
		HashMap<String, String> mRequestParams = new HashMap<String, String>();
		mRequestParams.put("chatid", chatId);
		mRequestParams.put("custids", delId);
		SetRequestParams(mRequestParams);
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) {
		RemoveGroupMemberInvokeItemResult result = new RemoveGroupMemberInvokeItemResult();
		JSONObject json = null;
		try {
			json = new JSONObject(responseBody);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		if (json == null) {
			return null;
		}
		result.status = json.optInt("status");
		result.msg = json.optString("msg");
		return result;
	}
}
